package com.jisf.driver.controller;

import com.jisf.driver.entity.vo.CoachMessageVo;
import com.jisf.driver.entity.vo.StudentMessageResponseVo;
import com.jisf.driver.entity.vo.StudentMessageVo;
import com.jisf.driver.entity.vo.UserListRequestVo;
import com.jisf.driver.response.Result;
import com.jisf.driver.response.ResultCode;
import com.jisf.driver.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jisf
 * @since 2022-05-06
 */
@RestController
@RequestMapping("/driver/student")
public class StudentController {

    @Autowired
    private IStudentService iStudentService;

    @GetMapping("getMessage")
    @PreAuthorize("hasAnyAuthority('student:getMessage')")
    public Result<?> getMessage(){
        StudentMessageVo message = iStudentService.getMessage();
        return Result.ok(message);
    }

    @PostMapping("completeMessage")
    @PreAuthorize("hasAnyAuthority('student:completeMessage')")
    public Result<?> completeMessage(@RequestBody StudentMessageVo studentMessageVo){
        ResultCode resultCode = iStudentService.completeMessage(studentMessageVo);
        return Result.ok(resultCode);
    }

    @PostMapping("allStudent")
    @PreAuthorize("hasAnyAuthority('student:allStudent')")
    public Result<?> allStudent(@RequestBody UserListRequestVo userListRequestVo){
        StudentMessageResponseVo message = iStudentService.allStudent(userListRequestVo);
        return Result.ok(message);
    }

    @PostMapping("update/student")
    @PreAuthorize("hasAnyAuthority('student:update:student')")
    public Result<?> updateStudent(@RequestBody StudentMessageVo studentMessageVo){
        ResultCode resultCode = iStudentService.updateStudent(studentMessageVo);
        return Result.ok(resultCode);
    }

}
